package com.gmq.chapter01.suspend;

/**
 * Created by gmq on 2017/08/10.
 *
 * @version 1.0
 * @since 2017/08/10 14:23
 */
public class SuspendRun {

    public static void main(String[] args) {

        try {

            SuspendThread thread = new SuspendThread();
            thread.start();
            Thread.sleep(5000);

            // A段
            thread.suspend();
            System.out.println("A=" + System.currentTimeMillis() + " i= " + thread.getI());

            Thread.sleep(5000);
            System.out.println("A=" + System.currentTimeMillis() + " i= " + thread.getI());

            // B段
            thread.resume();
            Thread.sleep(5000);

            // C段
            thread.suspend();
            System.out.println("C=" + System.currentTimeMillis() + " i= " + thread.getI());

            Thread.sleep(5000);
            System.out.println("C=" + System.currentTimeMillis() + " i= " + thread.getI());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
